﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;

namespace CourseSystem.Core
{
    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, AllowMultiple = false)]
    public class RangeValidation : ValidationAttribute
    {
        public int Min { get; set; }
        public int Max { get; set; }
        public override bool IsValid(object value)
        {
            int re;
            if (!int.TryParse(value.ToString(), out re))
                return false;
            if (re >= Min && re <= Max)
                return true;
            return false;
        }

    }
}
